from rest_framework_jwt.utils import jwt_payload_handler


def jwt_response_payload_handler(token, user=None, request=None):
    """
    自定义jwt认证成功返回数据
    """
    return {
        'token': token,
        'id': user.id,
        'username': user.username
    }


def meiduo_payload_handler(user):
    # 自定义载荷，调用自带的方法进行重写，删除邮件写入电话
    payload = jwt_payload_handler(user)
    del payload['email']
    payload['mobile'] = user.mobile
    return payload
